home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / Insets.java < prev    next >
Text File  |  1998-09-22  |  4KB  |  120 lines

  1. /*
  2.  * @(#)Insets.java    1.14 98/07/01
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  * 
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.awt;
  16.  
  17. /**
  18.  * An <code>Insets</code> object is a representation of the borders 
  19.  * of a container. It specifies the space that a container must leave 
  20.  * at each of its edges. The space can be a border, a blank space, or 
  21.  * a title. 
  22.  *
  23.  * @version     1.14, 07/01/98
  24.  * @author     Arthur van Hoff
  25.  * @author     Sami Shaio
  26.  * @see         java.awt.LayoutManager
  27.  * @see         java.awt.Container
  28.  * @since       JDK1.0
  29.  */
  30. public class Insets implements Cloneable, java.io.Serializable {
  31.  
  32.     /**
  33.      * The inset from the top.
  34.      * @since JDK1.0
  35.      */
  36.     public int top;
  37.  
  38.     /**
  39.      * The inset from the left.
  40.      * @since JDK1.0
  41.      */
  42.     public int left;
  43.  
  44.     /**
  45.      * The inset from the bottom.
  46.      * @since JDK1.0
  47.      */
  48.     public int bottom;
  49.  
  50.     /**
  51.      * The inset from the right.
  52.      * @since JDK1.0
  53.      */
  54.     public int right;
  55.  
  56.     /*
  57.      * JDK 1.1 serialVersionUID 
  58.      */
  59.     private static final long serialVersionUID = -2272572637695466749L;
  60.  
  61.     /**
  62.      * Creates and initializes a new <code>Insets</code> object with the 
  63.      * specified top, left, bottom, and right insets. 
  64.      * @param       top   the inset from the top.
  65.      * @param       left   the inset from the left.
  66.      * @param       bottom   the inset from the bottom.
  67.      * @param       right   the inset from the right.
  68.      * @since       JDK1.0
  69.      */
  70.     public Insets(int top, int left, int bottom, int right) {
  71.     this.top = top;
  72.     this.left = left;
  73.     this.bottom = bottom;
  74.     this.right = right;
  75.     }
  76.  
  77.     /**
  78.      * Checks whether two insets objects are equal. Two instances 
  79.      * of <code>Insets</code> are equal if the four integer values
  80.      * of the fields <code>top</code>, <code>left</code>, 
  81.      * <code>bottom</code>, and <code>right</code> are all equal.
  82.      * @return      <code>true</code> if the two insets are equal;
  83.      *                          otherwise <code>false</code>.
  84.      * @since       JDK1.1
  85.      */
  86.     public boolean equals(Object obj) {
  87.     if (obj instanceof Insets) {
  88.         Insets insets = (Insets)obj;
  89.         return ((top == insets.top) && (left == insets.left) &&
  90.             (bottom == insets.bottom) && (right == insets.right));
  91.     }
  92.     return false;
  93.     }
  94.  
  95.     /**
  96.      * Returns a <code>String</code> object representing this 
  97.      * <code>Insets</code> object's values.
  98.      * @return    a string representation of this <code>Insets</code> object, 
  99.      *                           including the values of its member fields.
  100.      * @since     JDK1.0
  101.      */
  102.     public String toString() {
  103.     return getClass().getName() + "[top="  + top + ",left=" + left + ",bottom=" + bottom + ",right=" + right + "]";
  104.     }
  105.  
  106.     /**
  107.      * Create a copy of this object.
  108.      * @return     a copy of this <code>Insets</code> object.
  109.      * @since      JDK1.0
  110.      */
  111.     public Object clone() { 
  112.     try { 
  113.         return super.clone();
  114.     } catch (CloneNotSupportedException e) { 
  115.         // this shouldn't happen, since we are Cloneable
  116.         throw new InternalError();
  117.     }
  118.     }
  119. }
  120.